package com.cssy.yd.logic.dao.impl;

import com.cssy.yd.logic.dao.LogicWhmoveOutwhDAO;
import com.cssy.yd.logic.entity.LogicWhmoveOutwhDO;
import com.plat.helper.SearchConditions;

import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

/**
 * 数据访问对象实现类
 * @since 2013-05-23
 */
public class LogicWhmoveOutwhDAOImpl extends SqlMapClientDaoSupport implements LogicWhmoveOutwhDAO {

    /**
     * 插入数据
     * @param logicWhmoveOutwhDO
     * @return 插入数据的主键
     */
    public String insertLogicWhmoveOutwhDO(LogicWhmoveOutwhDO logicWhmoveOutwhDO) throws DataAccessException {
    	logicWhmoveOutwhDO.setVersion(Double.parseDouble("1"));
    	Object id = getSqlMapClientTemplate().insert("LogicWhmoveOutwh.insert", logicWhmoveOutwhDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param logicWhmoveOutwhDO
     * @return 查出的记录数
     */
    public Integer countLogicWhmoveOutwhDOByExample(LogicWhmoveOutwhDO logicWhmoveOutwhDO) throws DataAccessException {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhmoveOutwh.countByDOExample", logicWhmoveOutwhDO);
        return count;
    }

    /**
     * 更新记录
     * @param logicWhmoveOutwhDO
     * @return 受影响的行数
     */
    public Integer updateLogicWhmoveOutwhDO(LogicWhmoveOutwhDO logicWhmoveOutwhDO) throws DataAccessException {
    	logicWhmoveOutwhDO.setVersionbt(logicWhmoveOutwhDO.getVersion());
    	logicWhmoveOutwhDO.setVersion(logicWhmoveOutwhDO.getVersion()+1);
    	int result = getSqlMapClientTemplate().update("LogicWhmoveOutwh.update", logicWhmoveOutwhDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param logicWhmoveOutwhDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<LogicWhmoveOutwhDO> findListByExample(LogicWhmoveOutwhDO logicWhmoveOutwhDO) throws DataAccessException {
        List<LogicWhmoveOutwhDO> list = getSqlMapClientTemplate().queryForList("LogicWhmoveOutwh.findListByDO", logicWhmoveOutwhDO);
        return list;
    }

    /**
     * 根据主键获取logicWhmoveOutwhDO
     * @param id
     * @return logicWhmoveOutwhDO
     */
    public LogicWhmoveOutwhDO findLogicWhmoveOutwhDOByPrimaryKey(String id) throws DataAccessException {
        LogicWhmoveOutwhDO logicWhmoveOutwhDO = (LogicWhmoveOutwhDO) getSqlMapClientTemplate().queryForObject("LogicWhmoveOutwh.findByPrimaryKey", id);
        return logicWhmoveOutwhDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteLogicWhmoveOutwhDOByPrimaryKey(String id) throws DataAccessException {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("LogicWhmoveOutwh.deleteByPrimaryKey", id);
        return rows;
    }

    @Override
    public List<LogicWhmoveOutwhDO> find(SearchConditions scs) throws DataAccessException{
		List<LogicWhmoveOutwhDO> list = getSqlMapClientTemplate().queryForList("LogicWhmoveOutwh_ex.find", scs);
   		   return list;
    }
    
	@Override
    public Integer count(SearchConditions scs) throws DataAccessException {		
		 Integer count = (Integer) getSqlMapClientTemplate().queryForObject("LogicWhmoveOutwh_ex.count", scs);
  	      return count;
  	}
}